<?php
/*
	本插件：$this->model('model')->方法名();
	其他地方调用：model('jy_shopxianhua/model')->方法名();
*/
namespace jy_shopxianhua;
defined('BY_JYA') or exit('error');
class model extends \plugin{
	public function getbaofee($goods=array()){
		$fee=$this->setting['baofee_shouprice'];
		$baofee_shou=$this->setting['baofee_shou'];
		$baofee_type=$this->setting['baofee_type'];
		$baofee_xu=$this->setting['baofee_xu'];
		$baofee_xuprice=$this->setting['baofee_xuprice'];
		if(!$baofee_xu || !$baofee_xuprice){
			return $fee;
		}
		$total_weight=0;
		$total_num=0;
		foreach($goods as $gv){
			$total_num+=$gv['total'];
			$total_weight+=$gv['total']*$gv['weight'];
		}
		if(!$baofee_type){
			if($total_weight>$baofee_shou){
				$rate=($total_weight-$baofee_shou)/$baofee_xu;
				$fee +=$rate*$baofee_xuprice;
				
			}
		}else{
			if($total_num>$baofee_shou && $baofee_xu){
				$rate=($total_num-$baofee_shou)/$baofee_xu;
				$fee +=$rate*$baofee_xuprice;
			}
		}
		return $fee;
	}
}
?>